var phoneReg=/^1[345789][0-9]{9}$/;
var pwdReg=/^.{6,16}$/;
var isPhoneRight =false;
var isPwdRight =false;

phone.onkeyup=function(){
    var phoneValue=phone.value;
    if(!phoneReg.test(phoneValue)){
        phoneerror.innerHTML="对不起您的手机号格式有误！";
        isPhoneRight=false;
    }else{
        phoneerror.innerHTML="";
        isPhoneRight=true;
    }
    checkAll();
};

pwd.onkeyup = function(){
    var pwdValue =pwd.value;
    if(!pwdReg.test(pwdValue)){
        pwderror.innerHTML="对不起您的密码格式有误！";
        isPwdRight =false;
    }else{
        pwderror.innerHTML="";
        isPwdRight=true;
    }
    checkAll();
};

function checkAll(){
    if(isPhoneRight&&isPwdRight){
        loginBtn.className ="loginBtn loginBtn_active";
    }else{
        loginBtn.className ="loginBtn";
    }
}

loginBtn.onclick = function(){
    if(this.className!="loginBtn"){
        loginBtn.innerHTML="登陆中";
        $.post("http://test.hfjava.com/shop/userlogin",  $("form").serialize(),
            function(data){
            loginBtn.innerHTML="登录";
            if(data=="false"){
                pwderror.innerHTML="您的用户名或密码有误，请重试！";
            }else{
                location.href = "index.html";
            }
            }
        );
    }
};